package com.fashion.service;

import com.fashion.dao.NewsColumnItemDao;
import com.fashion.model.News;
import com.fashion.model.NewsColumnItem;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: juventus
 * Date: 11-6-21
 */
@Service("newsColumnItemService")
public class NewsColumnItemServiceImpl implements NewsColumnItemService {
    private NewsColumnItemDao newsColumnItemDao;

    @Override
    public NewsColumnItem getNewsColumnItemById(String id) {
        return newsColumnItemDao.getEntityById(NewsColumnItem.class, id);
    }

    @Override
    public void saveOrUpdate(Object object) {
        newsColumnItemDao.saveOrUpdate(object);
    }

    @Override
    public void deleteEntityById(String id) {
        newsColumnItemDao.deleteById(id, NewsColumnItem.class);
    }

    @Override
    public void deleteEntity(Object object) {
        newsColumnItemDao.delete(object);
    }

    @Override
    public List<NewsColumnItem> findNewsColumnItemsByNews(News news) {
        return newsColumnItemDao.find("from NewsColumnItem i where i.newsId= ? ", news.getId());
    }

    @Resource(name = "newsColumnItemDao")
    public void setNewsColumnItemDao(NewsColumnItemDao newsColumnItemDao) {
        this.newsColumnItemDao = newsColumnItemDao;
    }
}
